package com.fz.us.admin.company.entity;


import com.fz.us.admin.company.bean.EnumManage;


import javax.persistence.*;
import java.util.Date;

/**
 * 实体类 - 登录账号
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-07-20 。
 * ============================================================================
 */
@Entity
@Table(name="sys_admin")
public class Admin extends CompanyEntity {


    private static final long serialVersionUID = 4346416437309466563L;
    public static final EnumManage.AccountEnum[] ACCOUNT_PASSWORD = new EnumManage.AccountEnum[]{EnumManage.AccountEnum.USERNAME, EnumManage.AccountEnum.MAIL, EnumManage.AccountEnum.MOBILE};
    public static final EnumManage.AccountEnum[] ACCOUNT_OPENID = new EnumManage.AccountEnum[]{EnumManage.AccountEnum.WEIXIN};


    /**
     * 用户名
     */
    private String username;
    private Boolean isUsernameEnabled;
    /**
     * 手机号
     */
    private String usermobile;
    private Boolean isMobileEnabled;
    /**
     * 邮箱
     */
    private String useremail;
    private Boolean isEmailEnabled;
    /**
     * 微信openId
     */
    private String openId;
    /**
     * 密码
     */
    private String password;
    /**
     * 密码加密盐值
     */
    private String salt;
    /**
     * token加密凭证
     */
    private String secret;
    /**
     * 账号的类型
     */
    private EnumManage.AccountEnum accountEnum;

    //----------------------------------------------------------------------------
    /**
     *  账号是否启用(账号激活时使用)
     */
    private Boolean isAccountEnabled;
    //----------------------------------------------------------------------------
    /**
     *  连续登录失败的次数(登录密码错误记录次数，持久化，存储到缓存)
     */
    private Integer loginFailureCount;
    /**
     *  账号是否锁定(账号冻结停用时使用)
     */
    private Boolean isAccountLocked;
    /**
     * 	账号锁定日期(操作停用时使用)
     */
    private Date lockedDate;
    //----------------------------------------------------------------------------
    /**
     *  凭证是否过期(登录超时需要重新登录)
     */
    private Boolean isCredentialsExpired;
    //----------------------------------------------------------------------------
    /**
     * 用户的账户类型
     */
    private EnumManage.AccountTypeEnum accountTypeEnum;
    /**
     * 账号到期日期
     */
    private Date expireDate;
    /**
     * 账号免费期到期日期，新建账号时赋值，管理员可修改
     */
    private Date freeExpireDate;
    /**
     *  账号是否过期（有效期到期，使用该功能，通过到期日期配合）
     */
    private Boolean isAccountExpired;
    //----------------------------------------------------------------------------
    /**
     *  最后登录日期（记录最后登陆日期，配合最后登陆的设备，通过LoginLog去实现）
     */
    private Date loginDate;
    /**
     *  最后登录IP
     */
    private String loginIp;
    //----------------------------------------------------------------------------
    /**
     * 最后一次使用的(在修改该记录时使用)
     */
    private String lastUsername;
    private String lastUsermobile;
    private String lastUseremail;
    private String lastOpenId;
    //----------------------------------------------------------------------------

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Boolean getIsUsernameEnabled() {
        return isUsernameEnabled;
    }

    public void setIsUsernameEnabled(Boolean usernameEnabled) {
        isUsernameEnabled = usernameEnabled;
    }

    public String getUsermobile() {
        return usermobile;
    }

    public void setUsermobile(String usermobile) {
        this.usermobile = usermobile;
    }

    public Boolean getIsMobileEnabled() {
        return isMobileEnabled;
    }

    public void setIsMobileEnabled(Boolean mobileEnabled) {
        isMobileEnabled = mobileEnabled;
    }

    public String getUseremail() {
        return useremail;
    }

    public void setUseremail(String useremail) {
        this.useremail = useremail;
    }

    public Boolean getIsEmailEnabled() {
        return isEmailEnabled;
    }

    public void setIsEmailEnabled(Boolean emailEnabled) {
        isEmailEnabled = emailEnabled;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    public EnumManage.AccountEnum getAccountEnum() {
        return accountEnum;
    }

    public void setAccountEnum(EnumManage.AccountEnum accountEnum) {
        this.accountEnum = accountEnum;
    }



    public Boolean getIsAccountEnabled() {
        return isAccountEnabled;
    }

    public void setIsAccountEnabled(Boolean accountEnabled) {
        isAccountEnabled = accountEnabled;
    }

    public Integer getLoginFailureCount() {
        return loginFailureCount;
    }

    public void setLoginFailureCount(Integer loginFailureCount) {
        this.loginFailureCount = loginFailureCount;
    }

    public Boolean getIsAccountLocked() {
        return isAccountLocked;
    }

    public void setIsAccountLocked(Boolean accountLocked) {
        isAccountLocked = accountLocked;
    }

    public Date getLockedDate() {
        return lockedDate;
    }

    public void setLockedDate(Date lockedDate) {
        this.lockedDate = lockedDate;
    }

    public Boolean getIsCredentialsExpired() {
        return isCredentialsExpired;
    }

    public void setIsCredentialsExpired(Boolean credentialsExpired) {
        isCredentialsExpired = credentialsExpired;
    }

    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    public EnumManage.AccountTypeEnum getAccountTypeEnum() {
        return accountTypeEnum;
    }

    public void setAccountTypeEnum(EnumManage.AccountTypeEnum accountTypeEnum) {
        this.accountTypeEnum = accountTypeEnum;
    }

    public Boolean getIsAccountExpired() {
        return isAccountExpired;
    }

    public void setIsAccountExpired(Boolean accountExpired) {
        isAccountExpired = accountExpired;
    }

    public Date getExpireDate() {
        return expireDate;
    }

    public void setExpireDate(Date expireDate) {
        this.expireDate = expireDate;
    }

    public Date getFreeExpireDate() {
        return freeExpireDate;
    }

    public void setFreeExpireDate(Date freeExpireDate) {
        this.freeExpireDate = freeExpireDate;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public String getLastUsername() {
        return lastUsername;
    }

    public void setLastUsername(String lastUsername) {
        this.lastUsername = lastUsername;
    }

    public String getLastUsermobile() {
        return lastUsermobile;
    }

    public void setLastUsermobile(String lastUsermobile) {
        this.lastUsermobile = lastUsermobile;
    }

    public String getLastUseremail() {
        return lastUseremail;
    }

    public void setLastUseremail(String lastUseremail) {
        this.lastUseremail = lastUseremail;
    }

    public String getLastOpenId() {
        return lastOpenId;
    }

    public void setLastOpenId(String lastOpenId) {
        this.lastOpenId = lastOpenId;
    }

}
